package langnstats.project.lib.crossvalidation;

import langnstats.project.Global;
import langnstats.project.lib.LanguageModel;
import langnstats.project.lib.WordType;

public class CrossValidationResultItem {

	private int size;
//	private int to;
	private double averageLL;
	public CrossValidationResultItem(int size, double ll) {
//		this.from = prevCutPoint;
		this.size = size;
		this.averageLL = ll;
	}
	public int getTokenCount(){ return size; }
	/*public int getFrom() {
		return from;
	}
	public int getTo() {
		return to;
	}*/
	public double getAverageLL() {
		return averageLL;
	}
	
	public CharSequence makeReport(){
		StringBuffer report = new StringBuffer();
		report.append("Token count: ").append(this.getTokenCount()).append(", LL: ").append(this.getAverageLL());
		return report;
	}

	public static CrossValidationResultItem evaluate(LanguageModel model, WordType[] evalTokens){
        double averageLL = Global.getAverageLogLikelihood(model, evalTokens);
        return new CrossValidationResultItem(evalTokens.length, averageLL);
	}
}
